#pragma once
#include "SimpleCanvas.h"

namespace yzrilyzr_simplecanvas{
	struct Rect{
		int32_t left=0;
		int32_t top=0;
		int32_t right=0;
		int32_t bottom=0;
		bool operator==(const Rect & rect)const{
			return
				left == rect.left &&
				top == rect.top &&
				right == rect.right &&
				bottom == rect.bottom;
		}
		bool operator!=(const Rect & rect)const{
			return
				left != rect.left ||
				top != rect.top ||
				right != rect.right ||
				bottom != rect.bottom;
		}
		bool isEmpty(){
			return left >= right || top >= bottom;
		}
		void set(Rect & rect){
			left= rect.left;
			top= rect.top;
			right= rect.right;
			bottom= rect.bottom;
		}
		void set(int32_t ll,int32_t tt,int32_t rr,int32_t bb){
			left= ll;
			top = tt;
			right= rr;
			bottom = bb;
		}
		int32_t width(){
			return right - left;
		}
		int32_t height(){
			return bottom - top;
		}
		int32_t centerX(){
			return left+width()/2;
		}
		int32_t centerY(){
			return top + height() / 2;
		}
	};
}